//package com.wushijia.mq; /**
// * Created by pc on 2017/11/7.
// */
//
//import com.aliyun.openservices.shade.com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
//import com.aliyun.openservices.shade.com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
//import com.aliyun.openservices.shade.com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
//import com.aliyun.openservices.shade.com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
//import com.aliyun.openservices.shade.com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
//import com.aliyun.openservices.shade.com.alibaba.rocketmq.common.message.Message;
//import com.aliyun.openservices.shade.com.alibaba.rocketmq.common.message.MessageExt;
//import java.util.List;
//
///**
// * 消费者测试
// *
// * @author houyangyang
// * @create 2017-11-07 18:18
// **/
//public class ConsumerTest {
//    public static void main(String[] args) {
//        /*Properties properties = new Properties();
//        // 您在MQ控制台创建的Consumer ID
//        properties.put(PropertyKeyConst.ConsumerId, "CID_chanceStage");
//        // 鉴权用AccessKey，在阿里云服务器管理控制台创建
//        properties.put(PropertyKeyConst.AccessKey, "jtnaiJaEFwoL57S1");
//        // 鉴权用SecretKey，在阿里云服务器管理控制台创建
//        properties.put(PropertyKeyConst.SecretKey, "OwZ9IR1ej6Uwf8d83rvSFo66TWnlld");
//        // 设置 TCP 接入域名（此处以公共云公网环境接入为例）
//        properties.put(PropertyKeyConst.ONSAddr,
//                "http://onsaddr-internet.aliyun.com/rocketmq/nsaddr4client-internet");*/
//        DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("pushconsumer");
//        consumer.setNamesrvAddr("127.0.0.1:9876");
//        try {
//            consumer.subscribe("PushTopic","push");
//            consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
//            consumer.registerMessageListener(new MessageListenerConcurrently() {
//                @Override
//                public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> list, ConsumeConcurrentlyContext consumeConcurrentlyContext) {
//                    Message message = list.get(0);
//                    System.out.println(message.toString());
//                    return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
//                }
//            });
//            consumer.start();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//        /*Consumer consumer = ONSFactory.createConsumer(properties);
//        consumer.subscribe("TopicTestMQ", "*", new MessageListener() {
//            public Action consume(Message message, ConsumeContext context) {
//                System.out.println("Receive: " + message);
//                return Action.CommitMessage;
//            }
//        });
//        consumer.start();*/
//        System.out.println("Consumer Started");
//    }
//}
